package me.goldze.mvvmhabit.utils;

import android.annotation.SuppressLint;
import android.content.Context;

import androidx.annotation.NonNull;

/**
 * Created by goldze on 2017/5/14.
 * 常用工具类
 */
public final class Utils {
    /**
     * 全局Context
     */
    @SuppressLint("StaticFieldLeak")
    private static Context context;

    /**
     * 默认名字
     */
    private static String APPName = "PACY";

    private Utils() {
        throw new UnsupportedOperationException("u can't instantiate me...");
    }

    /**
     * 初始化工具类
     *
     * @param context 上下文
     */
    public static void init(@NonNull final Context context) {
        Utils.context = context.getApplicationContext();
    }

    /**
     * 获取ApplicationContext
     *
     * @return ApplicationContext
     */
    public static Context getContext() {
        if (context != null) {
            return context;
        }
        throw new NullPointerException("should be initialized in application");
    }


    public static void setAPPName(String name) {
        APPName = name;
    }

    /**
     * 返回app名称
     *
     * @return
     */
    public static String getAPPName() {
        return APPName;
    }
//    /**
//     * 设置log tag
//     *
//     * @param tag logtag
//     */
//    public static void setLogTag(String tag) {
//        KLog.setLogTag(tag);
//    }
}